package tum0r.server.problem.misc.steganography;

import tum0r.model.ProblemInfoItem;
import tum0r.model.ProblemLevel;
import tum0r.server.problem.ProblemBase;
import tum0r.webengine.annotation.Server;
import tum0r.webengine.model.server.EngineFile;
import tum0r.webengine.utils.server.action.Action;

import java.io.IOException;

/**
 * 工程: Security<br>
 * 包: tum0r.server.problem.misc.steganography<br>
 * 创建者: tum0r<br>
 * 创建时间: 2021/3/21 17:20<br>
 * <br>
 */
@Server(Mapping = "/security/problem/misc/steganography/text")
public class Text extends ProblemBase {
    public Text() {
        information.ProblemTitle = "文本文档隐写";
        information.ProblemID = 7;
        information.Creator = "tum0r";
        information.ProblemLevel = ProblemLevel.FUNNY;
        information.CreateTime = "2020/03/21";
        ProblemInfoItem problem = new ProblemInfoItem("problem", null);
        information.ProblemInfo.add(problem);
    }

    @Override
    public void description(Action<String> action) {
        action.callBack("嘿嘿嘿，你能打开这个文件吗？小心爆炸！");
    }

    @Override
    public void tips(Action<String> action) {
        action.callBack(null);
    }

    @Override
    public void writeUp(Action<String> action) {
        action.callBack("""
                0、压缩包文件名是转码后的密码
                                
                1、用一个能打开4GB文本文档的软件打开解压出来的ReadMe.md
                                
                2、在文件最后有flag
                """);
    }

    public void problem(Action<EngineFile> action) throws IOException, InterruptedException {
        EngineFile result = new EngineFile();
        result.read("Files/u0043u0040u006eu0059u0030u0075u004fu0070u0033u006eu004du0033u003f.7z");
        action.callBack(result);
    }
}
